﻿using RamGecTools;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Drawing;

namespace Settings4Net_Test
{
    
    
    /// <summary>
    ///This is a test class for ItemTest and is intended
    ///to contain all ItemTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ItemTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Item`1 Constructor
        ///</summary>
        public void ItemConstructorTestHelper<T>(string name, T value, bool? ro, T min, T max, T def, SettingsMetaData meta)
        {
            string Name = name; // TODO: Initialize to an appropriate value
            T Value = value; // TODO: Initialize to an appropriate value
            Nullable<DateTime> ModifiedDate = new Nullable<DateTime>(); // TODO: Initialize to an appropriate value
            Nullable<bool> Readonly = ro; // TODO: Initialize to an appropriate value
            T MinValue = min; // TODO: Initialize to an appropriate value
            T MaxValue = max; // TODO: Initialize to an appropriate value
            T Default = def; // TODO: Initialize to an appropriate value
            Item<T> target = new Item<T>(Name, Value, ModifiedDate, Readonly, MinValue, MaxValue, Default, meta);

            Assert.AreEqual(target.Name, name);
            Assert.AreEqual(target.Value, value);
            Assert.AreEqual(target.Readonly, ro);
            Assert.AreEqual(target.MinValue, min);
            Assert.AreEqual(target.MaxValue, max);
            Assert.AreEqual(target.Default, def);
        }

        [TestMethod()]
        public void ItemConstructorTest()
        {
            ItemConstructorTestHelper<string>("name", "stringvalue", true, null, null, "default", null);
            ItemConstructorTestHelper<int?>("name", 10, true, 1, 12, 9, null);
            ItemConstructorTestHelper<bool?>("name", true, true, null, null, true, null);
            ItemConstructorTestHelper<double?>("name", 1.1, true, 1, 1.2, 1.123, null);
            ItemConstructorTestHelper<Color?>("name", Color.Red, true, null, null, Color.Blue, null);
            ItemConstructorTestHelper<DateTime?>("name", new DateTime(1985, 8, 20, 2, 55, 0), true, new DateTime(1980, 8, 20, 2, 55, 0), new DateTime(1990, 8, 20, 2, 55, 0), new DateTime(1985, 8, 20, 2, 55, 0), null);
            ItemConstructorTestHelper<Font>("name", new Font("Arial", 2), true, null, null, new Font("Arial", 2), null);
        }
    }
}
